
Object.prototype.toTestNum = function () {
    var num = this
    return `-${num}-`
}

var obj = {}

var func = () => { }

var attr = []

var str = new String("")

var num = 1

console.log(num.toTestNum().toTestNum())

// 自己实现 instanceOf
const instanceOf = (A, B) => {
    let p = A
    while (p) {
        if (p === B.prototype) return true
        p = p.__proto__
    }
    return false
}


console.log(instanceOf(1, Object))
console.log(str.constructor == String)              //找到构造函数  
console.log(str.__proto__ == String.prototype)      //通过 __proto__ 找到构构造方法的 prototype

console.log(Object.__proto__==Function.prototype)   //Object对象是Function对象的一个实例
console.log(Array.__proto__==Function.prototype)    //基础数据结构继承自